# Python中的垃圾回收是以引用计数为主，标记-清除和分代收集为辅
import sys
import gc
import time
class A:
    pass
print(gc.get_count())
# while True:
#     A()

a = [1]
b = [2]
a[0]= b

b[0] = a
print(sys.getrefcount(a))
for i in range(100):
    print(i)
    A()
    time.sleep(1)
    print(gc.get_count())

print(gc.garbage)
# # print(sys.getrefcount(a))
# gc.disable()
# print(gc.isenabled())
# gc.collect(2)
print(gc.get_count())
print(gc.garbage)
print()

# l = [1]
# l.append(l)
# del l
# a = [1]
# b = [2]
# a.append(b)
# b.append(a)
# del a


# print(a)
# print(b)
# print(len(b))